const fs = require('fs');
const path = require('path');

const themesDir = path.join(__dirname, 'src/themes');
const indexFile = path.join(themesDir, 'index.scss');

// 读取 themes 文件夹中的所有文件
fs.readdir(themesDir, (err, files) => {
  if (err) {
    console.error("Could not list the directory.", err);
    process.exit(1);
  }

  const scssFiles = files.filter(file => file.endsWith('.scss') && file !== 'index.scss');
  const imports = scssFiles.map(file => `@import '${file}';`).join('\n');

  // 将 import 语句写入 index.scss 文件
  fs.writeFile(indexFile, imports, (err) => {
    if (err) throw err;
    console.log('index.scss has been updated with all scss files in themes directory!');
  });
});
